package com.banciyuan.bcywebview.biz.main.mainpage.timeline.viewholder;

import android.support.v7.widget.RecyclerView;
import android.text.Html;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.banciyuan.bcywebview.R;
import com.banciyuan.bcywebview.utils.universalimageloader.core.ImageLoader;
import com.banciyuan.bcywebview.utils.universalimageloader.utils.ImageOptions;

import de.greenrobot.daoexample.model.Timeline;

/**
 * Created by squall on 2017/6/22.
 */

public class GridGroupHolder extends RecyclerView.ViewHolder {

    private ImageView mCover;
    private TextView mIntro;

    public GridGroupHolder(View itemView) {
        super(itemView);
        mIntro = (TextView) itemView.findViewById(R.id.item_intro);
        mCover = (ImageView) itemView.findViewById(R.id.item_cover);
    }

    public void setGridgroup(GridGroupHolder gridGroupHolder, Timeline mItem, View.OnClickListener onClickListener) {
        if (!TextUtils.isEmpty(mItem.getPlain())) {
            gridGroupHolder.mIntro.setText(Html.fromHtml(mItem.getPlain()));
        }
        if (!TextUtils.isEmpty(mItem.getCover())) {
            gridGroupHolder.mCover.setVisibility(View.VISIBLE);
            ImageLoader.getInstance().displayImage(mItem.getCover(), gridGroupHolder.mCover, ImageOptions.options);
        } else {
            gridGroupHolder.mCover.setVisibility(View.GONE);
        }
        gridGroupHolder.itemView.setOnClickListener(onClickListener);
    }
}
